import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    count: 0,
    doctorList: [],
    Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
  },
  mutations: {
    changeLogin(state, user) {
      state.Authorization = user.Authorization
      localStorage.setItem('Authorization', user.Authorization)
    },
    getDotsById(state, payload) {
      state.doctorList = payload
    }
  },
  actions: {
    // async getDotsById(id) {
    //   const res = await this.$http.getDotsById(id)
    //   this.doctorList = res.data
    //   console.log(this.doctorList)
    // },
    async getDotsById({ commit }, id) {
      const res = await this.$http.getDotsById(id)
      // this.doctorList = res.data
      commit('getDotsById', res.data)
      // console.log(this.doctorList)
    }
  }
})

export default store
